import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sp_util/sp_util.dart';
import 'package:yp/config/index.dart';
import 'package:yp/config/style.dart';
import 'package:yp/router.dart';
import 'package:yp/services/api.dart';
import 'package:yp/widgets/bottom_sheet.dart';
import 'package:yp/widgets/button_widget.dart';
import 'package:yp/widgets/dialog.dart';
import 'package:yp/widgets/index.dart';

class Marketing extends StatefulWidget {
  const Marketing({Key key}) : super(key: key);

  @override
  _MarketingState createState() => _MarketingState();
}

class _MarketingState extends State<Marketing> with SingleTickerProviderStateMixin {
  AnimationController _controller;
  List<Map<String, dynamic>> _list = [
    {
      'id': '1',
      'name': '规格',
      'list': [
        {'id': '1', 'name': '规格1', 'isSelect': false},
        {'id': '2', 'name': '规格2', 'isSelect': false},
        {'id': '3', 'name': '规格3', 'isSelect': false},
        {'id': '4', 'name': '规格4', 'isSelect': false},
        {'id': '5', 'name': '规格5', 'isSelect': false},
        {'id': '6', 'name': '规格6', 'isSelect': false},
        {'id': '7', 'name': '规格7', 'isSelect': false},
        {'id': '8', 'name': '规格8很长很长足够长非常的长', 'isSelect': false}
      ]
    },
    {
      'id': '2',
      'name': '型号',
      'list': [
        {'id': '1', 'name': '型号1型号1型号1型号1', 'isSelect': false},
        {'id': '2', 'name': '型号2', 'isSelect': false},
        {'id': '3', 'name': '型号3型号3型号3型号3', 'isSelect': false},
        {'id': '4', 'name': '型号4', 'isSelect': false}
      ]
    },
    {
      'id': '3',
      'name': '样式',
      'list': [
        {'id': '1', 'name': '样式1', 'isSelect': false},
        {'id': '2', 'name': '样式2', 'isSelect': false},
        {'id': '3', 'name': '样式3', 'isSelect': false},
        {'id': '4', 'name': '样式4', 'isSelect': false},
        {'id': '5', 'name': '样式5', 'isSelect': false},
        {'id': '6', 'name': '样式6', 'isSelect': false}
      ]
    }
  ];

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: YPNavigationBar('营销活动', backgroundColor: EsColors.Primary, showBack: false, titleColor: EsColors.White),
      body: Padding(
          padding: const EdgeInsets.all(18.0),
          child: Wrap(
            runSpacing: 16,
            spacing: 16,
            children: [
              EsOutLineButton('消费有礼', padding: EdgeInsets.all(8), onTap: () {
                Get.toNamed(RouteConfig.consumeGift);
              }),
              // EsOutLineButton('活动规则', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.activityRule);
              // }),
              // EsOutLineButton('评价成功', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.commentSuccess);
              // }),
              // EsOutLineButton('完善会员奖励', padding: EdgeInsets.all(8), onTap: () {
              //   YpShowDialog.showCompleteMemberReward(context);
              // }),
              // EsOutLineButton('我的分享', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.myShare);
              // }),
              // EsOutLineButton('分享有礼', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.shareGift);
              // }),
              // EsOutLineButton('分享', padding: EdgeInsets.all(8), onTap: () {
              //   YpBottomSheet.showShareGift(context, (selectIndex, selectString,
              //       {info, list}) {
              //     print(selectIndex.toString() + selectString);
              //   });
              // }),
              // EsOutLineButton('助力摇奖', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.bigTurntable);
              // }),
              // EsOutLineButton('选择规格', padding: EdgeInsets.all(8), onTap: () {
              //   YpBottomSheet.showSpecification(context, _list,
              //       (selectIndex, selectString, {info}) {
              //     print(info);
              //   });
              // }),
              // EsOutLineButton('获取抽奖机会', padding: EdgeInsets.all(8), onTap: () {
              //   YpShowDialog.showAchieveChance(context);
              // }),
              // EsOutLineButton('抱歉，没中奖', padding: EdgeInsets.all(8), onTap: () {
              //   YpShowDialog.showSorry(context);
              // }),
              // EsOutLineButton('恭喜，中奖了', padding: EdgeInsets.all(8), onTap: () {
              //   YpShowDialog.showCongratulations(context, () {
              //     print('查看奖品');
              //   });
              // }),
              // EsOutLineButton('拼团订单', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.tuanOrder);
              // }),
              // EsOutLineButton('拼团热销榜', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.salesRankings);
              // }),
              // EsOutLineButton('活动规则', padding: EdgeInsets.all(8), onTap: () {
              //   YpShowDialog.showActivitiesRule(context);
              // }),
              // EsOutLineButton('积分商城', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.integralMall);
              // }),
              // EsOutLineButton('活动说明', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.helpLottery);
              // }),
              // EsOutLineButton('拼手气红包', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.randomAmount);
              // }),
              // EsOutLineButton('会员任务', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.vipTask);
              // }),
              // EsOutLineButton('领取优惠券', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.collectCoupons);
              // }),
              // EsOutLineButton('秒杀活动', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.seckillHome);
              // }),
              // EsOutLineButton('大转盘', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.roundAbout);
              // }),
              // EsOutLineButton('领券中心', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.collectCouponsCenter);
              // }),
              // EsOutLineButton('查看券', padding: EdgeInsets.all(8), onTap: () {
              //   YpBottomSheet.showCouponDetial(context, ({info}) {});
              // }),
              // EsOutLineButton('邀请好友有礼', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.inviteFriend);
              // }),
              // EsOutLineButton('参团详情', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.joinGroup);
              // }),
              EsOutLineButton('申请成为惠达人', padding: EdgeInsets.all(8), onTap: () {
                var params = {
                  'leader_usr_num_id': SpUtil.getInt('empeNumId'),
                  "access_token": SpUtil.getString('token'),
                };

                Api.applyquery(params).listen((event) {
                  if (event['code'] == 0) {
                    if(event['distribution_salesperson_apply'] == null){
                          Get.toNamed(RouteConfig.applyExpert);

                    }else{
                          // Get.toNamed(RouteConfig.applyExpert);
                        Get.toNamed(RouteConfig.expertUnderReview);
                    }
                  }
                });

              }),
              // EsOutLineButton('申请成功', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.applyExpertSuccess);
              // }),
              // EsOutLineButton('拼团列表', padding: EdgeInsets.all(8), onTap: () {
              //   YpShowDialog.showGroupList(context);
              // }),
              // EsOutLineButton('超值拼团', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.collage);
              // }),
              EsOutLineButton('发现', padding: EdgeInsets.all(8), onTap: () {
                Get.toNamed(RouteConfig.discover);
              }),
              // EsOutLineButton('活动详情', padding: EdgeInsets.all(8), onTap: () {
              //   Get.toNamed(RouteConfig.eventDetail);
              // }),
            ],
          )),
    );
  }
}
